<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head >
    <title>添加店铺流量记录</title>
    <link rel="stylesheet" href="/layui/css/layui.css">
    <script src="/layui/layui.js"></script>
    <script>
        var index = 0;
        try{
            index = parent.layer.getFrameIndex(window.name); //获取窗口索引
        }catch (e) {
        }
    </script>
</head>
<body >

<div class="layui-body" style="padding-top:20px;">
    
    <div class="sp-wrapper">
        <div class="order-body">

            <form method="post" class="layui-form" id="sp-form">
                <div class="layui-form-item">
                    <label class="layui-form-label">店铺：</label>
                    <div class="layui-input-inline">
                        <select name="shopId" id="shopId" lay-verify="required">
                            <option value="" selected>请选择店铺</option>
                            <option  th:each="item: ${shops}" th:text="${item.name + ' - '+ item.typeName}" th:value="${item.id}">等待发货</option>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">来源：</label>
                    <div class="layui-input-inline">
                        <select name="source" lay-verify="required">
                            <option value="unknown" selected>未知</option>
                            <option value="search">搜索</option>
                            <option value="recommend">商城推荐</option>
                            <option value="chuchuang">橱窗</option>
                            <option value="gouhouyemian">购后页面</option>
                            <option value="dianpuye">店铺页</option>
                            <option value="other">其他</option>
                            <option value="dashboard">总览</option>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">曝光量</label>
                    <div class="layui-inline" >
                        <input type="text" name="shows"  placeholder="曝光量" lay-verify="required|number" autocomplete="off" class="layui-input">
                    </div>
                    <div class="layui-inline">
                        <input type="text" name="paidShows"  placeholder="付费曝光量"  autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">点击人数</label>
                    <div class="layui-inline">
                        <input type="text" name="visits"  placeholder="点击人数" lay-verify="required|number"  autocomplete="off" class="layui-input">
                    </div>
                    <div class="layui-inline">
                        <input type="text" name="visitsFs"  placeholder="老客点击人数" lay-verify="required|number" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">点击次数</label>
                    <div class="layui-input-inline">
                        <input type="text" name="views" lay-verify="required|number" placeholder="点击次数" autocomplete="off" class="layui-input">
                    </div>
                    <div class="layui-inline">
                        <input type="text" name="CTR" placeholder="点击率" lay-verify="required" autocomplete="off" class="layui-input">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">成交</label>
                    <div class="layui-inline">
                        <input type="text" name="orderUsers"  placeholder="成交人数" lay-verify="required" autocomplete="off" class="layui-input">
                    </div>
                    <div class="layui-inline">
                        <input type="text" name="orderNewUsers" placeholder="首购新客数" lay-verify="required" autocomplete="off" class="layui-input">
                    </div>
                </div>


                <div class="layui-form-item">
                    <label class="layui-form-label">成交</label>
                    <div class="layui-inline">
                        <input type="text" name="orderAmount"  placeholder="成交金额" lay-verify="required"  autocomplete="off" class="layui-input">
                    </div>
                    <div class="layui-inline">
                        <input type="text" name="CVR" placeholder="成交转化率" lay-verify="required" autocomplete="off" class="layui-input">
                    </div>
                </div>


                <div class="layui-form-item">
                    <label class="layui-form-label">转化</label>
                    <div class="layui-inline">
                        <input type="text" name="ATV"  placeholder="客单价" lay-verify="required" autocomplete="off" class="layui-input">
                    </div>
                    <div class="layui-inline">
                        <input type="text" name="UVV"  placeholder="UV价值" lay-verify="required" autocomplete="off" class="layui-input">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">日期</label>
                    <div class="layui-input-inline">
                        <input type="text" name="date" id="date" lay-verify="required" th:value="${date}" readonly placeholder="" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">备注</label>
                    <div class="layui-input-inline">
                        <input type="text" name="remark" placeholder="" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button class="layui-btn" lay-submit lay-filter="add_btn">立即提交</button>
                        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                    </div>
                </div>
            </form>
        </div>
    <script type="text/javascript" src="/sb/jquery.min.js"></script>
    <script type="text/javascript" src="/sb/Tips.min.js"></script>

    <!-- end sp-wrapper -->
    <script>
        layui.use(['laydate', 'form','layer'], function () {
            var laydate = layui.laydate;
            var form = layui.form;
            var layer = layui.layer;

            //执行一个laydate实例
            laydate.render({
                elem: '#date' //指定元素
            });
            $(function(){
                
                $("#shopId").val([[${shopId}]]);
                form.render('select');

                form.on('submit(add_btn)', function(data){
                console.log(data.field);
                $.ajax({
                    type:"POST",
                    url:"/shop/shop_traffic_dy_add_ajax",
                    processData: false, //表明不要对数据进行处理
                    data:JSON.stringify(data.field),
                    contentType: 'application/json',
                    success:function (res) {
                        if(res.code == 0){
                            parent.layer.msg(res.msg)
                            parent.layer.close(index);
                            parent.location.reload();
                        }else {
                            layer.msg(res.msg)
                        }
                        return false;
                    }
                });
                return false;
            });

            })

            
        });

    </script>
      </div>
    </div>
</div>
</body>
<html>
